# 生成的新镜像以centos镜像为基础
FROM centos
# 指定作者信息
MAINTAINER by caorl
# 复制nginx到镜像中,ADD会自动解压tar,xz,gzip,COPY是仅复制
ADD nginx.tar.gz /usr/local

# 设置工作空间
WORKDIR /usr/local/nginx

# 构建镜像时调用
RUN ["echo","buildingImage"]
# -y自动安装
# RUN 指令通常用于安装应用和软件包
RUN ["yum","install","-y","net-tools"]

# 暴露端口，只是暴露出去（不写也不影响，规范还是写），容器使用还需要使用-p做端口映射
EXPOSE 1935
EXPOSE 81

# 单独使用CMD或者ENTRYPOINT
# daemon off不以守护进程方式运行，这样容器才能一直运行
#CMD ["/usr/local/nginx/sbin/nginx","-g","daemon off;"]
#ENTRYPOINT ["/usr/local/nginx/sbin/nginx","-g","daemon off;"]

# CMD只有一个，后面的会覆盖前面的
CMD ["/bin/bash","-c","echo 'hello,docker';"]
CMD ["/bin/bash","-c","echo 'hello,docker overwrite';"]

#执行多个命令，用&&连接或者用entrypoint指定sh脚本
CMD sh -c "echo 'hello,docker' && echo 'hello,docker2'"

# CMD作为ENTRYPOINT的参数,CMD可以在docker run时覆盖，比如docker run --name test  nginx-rtmp:v1 -g "daemon off;"
# ENTRYPOINT也可以通过--entrypoint覆盖,  比如docker run --name test-name  --entrypoint=/usr/local/nginx/sbin/nginx  nginx-rtmp:v1 -g "daemon off;"
CMD ["-g","daemon off;"]
ENTRYPOINT ["/usr/local/nginx/sbin/nginx"]

